package com.qqzone.qq.dao.impl;

import com.qqzone.myssm.basedao.BaseDAO;
import com.qqzone.qq.dao.TopicDao;
import com.qqzone.qq.pojo.Topic;
import com.qqzone.qq.pojo.UserBasic;

import java.util.List;

public class TopicDaoImpl extends BaseDAO<Topic> implements TopicDao {
    @Override
    public List<Topic> getTopicList(UserBasic userBasic) {
        return super.executeQuery("select * from t_topic where author = ?", userBasic.getId());
    }

    @Override
    public int addTopic(Topic topic) {
        return super.executeUpdate("insert into t_topic values(null,?,?,?,?)", topic.getTitle(),topic.getContent(),topic.getTopicDate(),topic.getAuthor().getId());
    }

    @Override
    public int delTopic(Topic topic) {
        return super.executeUpdate("delete from t_topic where id = ?", topic.getId());
    }

    @Override
    public Topic getTopic(Integer id) {
        return super.load("select * from t_topic where id = ?", id);
    }
}
